<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
<link rel="stylesheet" href="layui/css/layui.css">
<script src="layui/layui.js"></script>
</head>
<body>
	<script type="text/javascript">
	layui.use([ 'layer', 'form', 'jquery', 'table', 'upload' ], function() {
		var layer = layui.layer;//声明对话框组件
		var form = layui.form;//声明表单组件
		var $ = layui.jquery;//声明jquery组件
		var table = layui.table;//声明table组件
		var upload = layui.upload;
		  
		  layer.open({//定义登录的对话框浮层
			  content: $('#register-dialog').html(),
			  title:'顾客注册',
			  type: 1,
			  closeBtn:0
			});
		  form.render();
		  
		  //登录提交表单
		  form.on('submit(register-submit)',function(data){
			  console.log(data.field)//当前容器的全部表单字段，名值对形式:{name,value}
			  $.post('buyer/register',data.field,function(flag){
				 console.log(flag);
				 if(flag)
					 {
					 alert('注册成功')
					 window.location.href="login.jsp";
					 }
				 else{
					 alert('注册失败')
				 }
			  })
			  return false;//阻止表单跳转。如果需要跳转，去掉本段
		  });
		});
	
	</script>

	<script type="text/html" id="register-dialog">
		<form class="layui-form" method="post">

		<div class="layui-form-item">
		<label class="layui-form-label">买家名称</label>
		<div class="layui-input-inline">
		<input type="text" name="bname" required lay-verify="required"
					placeholder="请输入买家名称" class="layui-input">
		</div>
		</div>

		<div class="layui-form-item">
		<label class="layui-form-label">性别</label>
		<div class="layui-input-block">
		  <select name="sex" lay-verify="">
             <option value="">请选择</option>
             <option value="男">男</option>
		     <option value="女">女</option>
		  </select>  
		</div>   
		</div>

		<div class="layui-form-item">
		<label class="layui-form-label">年龄</label>
		<div class="layui-input-inline">
		<input type="text" name="age" required lay-verify="required"
					placeholder="年龄" class="layui-input">
		</div>
		</div>

 		<div class="layui-form-item">
		<label class="layui-form-label">电话</label>
		<div class="layui-input-inline">
		<input type="text" name="tel" required lay-verify="required"
					placeholder="电话" class="layui-input">
		</div>
		</div>

		<div class="layui-form-item">
		<label class="layui-form-label">邮箱</label>
		<div class="layui-input-inline">
		<input type="text" name="email" required lay-verify="required"
					placeholder="邮箱" class="layui-input">
		</div>
		</div>

        <div class="layui-form-item">
		<label class="layui-form-label">地址</label>
		<div class="layui-input-inline">
		<input type="text" name="address" required lay-verify="required"
					placeholder="地址" class="layui-input">
		</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">用户密码</label>
			<div class="layui-input-inline">
				<input type="password" name="password" required
					lay-verify="required" placeholder="请输入密码" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="register-submit">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>

<a href="login.jsp" class="layui-btn" id="login-type">顾客登录</a>
<a href="adminLogin.jsp" class="layui-btn" id="login-type">管理登录</a>
	</script>



</body>
</html>